package main

import (
	"github.com/gin-gonic/gin"
	"log"
)

func main() {

	engine := gin.Default()

	routerGroup := engine.Group("/user")
	routerGroup.GET("", GetUserHandle)
	routerGroup.POST("", AddUserHandle)
	routerGroup.PUT("", EditUserHandle)
	routerGroup.DELETE("/:id", DeleteUserHandle)


	if err := engine.Run(":8080"); err != nil {
		log.Fatal(err.Error())
	}

}

func GetUserHandle(context *gin.Context) {
	context.Writer.WriteString("查询")
}

func DeleteUserHandle(context *gin.Context) {
	id := context.Param("id")
	context.Writer.WriteString("删除 " + id)
}

func EditUserHandle(context *gin.Context) {
	context.Writer.WriteString("更新")
}

func AddUserHandle(context *gin.Context) {
	context.Writer.WriteString("添加")
}
